//
//  EDSBaseModel.m
//  DriveSchoolCoach
//
//  Created by TangBin on 2019/7/8.
//  Copyright © 2019 TangBin. All rights reserved.
//

#import "TYZBaseModel.h"

@implementation TYZBaseModel

//+ (NSDictionary *)modelContainerPropertyGenericClass {
//    return @{@"moments" : [MHMoment class]};
//}


//+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper;

/**
 将Json（NSData，NSString，NSDictionary）转成Model
 
 @param json json description
 @return model
 */
+ (instancetype)tyz_modelWithJson:(id)json
{
    return [self yy_modelWithJSON:json];
}

/**
 字段转模型
 
 @param dict dict description
 @return model
 */
+ (instancetype)tyz_modelWithDictionary:(NSDictionary *)dict
{
    return [self yy_modelWithDictionary:dict];
}

/**
 json转模型数组
 
 @param json json description
 @return return value description
 */
+ (NSArray *)tyz_modelArrayWithJson:(id)json
{
    return [NSArray yy_modelArrayWithClass:[self class] json:json];
}


/**
 将model转成json对象
 
 @return return value description
 */
- (id)toJsonObject
{
    return [self yy_modelToJSONObject];
}

/**
 将model转成NSData
 
 @return return value description
 */
- (NSData *)toJsonData
{
    return [self yy_modelToJSONData];
}

/**
 将model转成string
 
 @return return value description
 */
- (NSString *)toJsonString
{
    return [self yy_modelToJSONString];
}

#pragma mark - Codeing/Copying/hash/equal
- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [self yy_modelEncodeWithCoder:aCoder];
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
    return [self yy_modelInitWithCoder:aDecoder];
}
- (id)copyWithZone:(NSZone *)zone
{
    return [self yy_modelCopy];
}
- (NSUInteger)hash
{
    return [self yy_modelHash];
}
- (BOOL)isEqual:(id)object
{
    return [self yy_modelIsEqual:object];
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    NSLog(@"undefineKey=%@", key);
}
- (NSString *)description
{
    return [self yy_modelDescription];
}

//+ (NSSet *)propertyKeys
//{
//    NSSet *cachedKeys = objc_getAssociatedObject(self, EDSObjectCachedPropertyKeysKey);
//    if (cachedKeys != nil)
//    {
//        return cachedKeys;
//    }
//
//    NSMutableSet *keys = [NSMutableSet set];
//
//    [self enumeratePropertiesUsingBlock:^(objc_property_t property, BOOL *stop) {
//
//    }];
//
//    objc_setAssociatedObject(self, EDSObjectCachedPropertyKeysKey, keys, OBJC_ASSOCIATION_COPY);
//
//    return keys;
//}

/*
 #pragma mark Reflection
 + (void)enumeratePropertiesUsingBlock:(void (^)(objc_property_t property, BOOL *stop))block {
 Class cls = self;
 BOOL stop = NO;
 
 while (!stop && ![cls isEqual:EDSBaseObject.class])
 {
 unsigned count = 0;
 objc_property_t *properties = class_copyPropertyList(cls, &count);
 
 cls = cls.superclass;
 if (properties == NULL) continue;
 
 //        @onExit {
 free(properties);
 //        };
 
 for (unsigned i = 0; i < count; i++) {
 block(properties[i], &stop);
 if (stop) break;
 }
 }
 }*/

@end
